import { Button, Table } from 'antd';
import { PlusOutlined } from '@ant-design/icons'
import styles from './index.less';
import { useDispatch, useSelector } from 'umi';
import { useEffect, useState } from 'react';
import { MenuModelState } from '@/models/sys-menu';

function prodProdTag() {
    // const menuList = useSelector((state: { menuList: MenuModelState}) => state.menuList);
    // console.log(menuList,'menuList...');
    
    //icon: null
    // list: null
    // menuId: 7
    // name: "查看"
    // orderNum: 0
    // parentId: 6
    // parentName: null
    // perms: "sys:schedule:page,sys:schedule:info"
    // type: 2
    // url: null
    const menuList = JSON.parse(localStorage.getItem('menuList') as any);
    console.log(menuList,'menuList2...');
     
    const dispatch = useDispatch();
    useEffect(()=>{
        dispatch({
            type:'sys-menu/getMenuList',
        })
    },[])
    // 删除
    // 删除接口
    async function delfirm(text: any) {
        // await dispatch({
        //     type: 'page/delPageList',
        //     payload: text.id
        // })

        // await dispatch({
        //     type: 'page/getPageList',
        //     payload: page
        // })

    }

    // 表格配置
    const columns = [
        {
            title: '名称',
            dataIndex: 'name',
            key: 'name',
            align: 'center'
        },
        {
            title: '图标',
            dataIndex: 'age',
            width:'10%',
            key: 'age',
            align: 'center'
        },
        {
            title: '类型',
            dataIndex: 'address',
            width:'10%',
            key: 'address',
            align: 'center'
        },
        {
            title: '排序号',
            dataIndex: 'address',
            width:'10%',
            key: 'address',
            align: 'center'
        },
        {
            title: '菜单URL',
            dataIndex: 'address',
            key: 'address',
            align: 'center'
        },
        {
            title: '授权标识',
            dataIndex: 'address',
            key: 'address',
             align: 'center'
        },
        {
            title: '操作',
            dataIndex: '',
            align: 'center',
            width:'15%',
            key: 'x',
            render: (a:any,b:any) => {
                return <div>
                    <a>修改</a>
                    <a>删除</a>
                </div>
            }
        }
    ];
    const data = [
        {
            key: 1,
            name: 'John Brown sr.',
            age: 60,
            address: 'New York No. 1 Lake Park',
            children: [
                {
                    key: 11,
                    name: 'John Brown',
                    age: 42,
                    address: 'New York No. 2 Lake Park',
                },
                {
                    key: 12,
                    name: 'John Brown jr.',
                    age: 30,
                    address: 'New York No. 3 Lake Park',
                    children: [
                        {
                            key: 121,
                            name: 'Jimmy Brown',
                            age: 16,
                            address: 'New York No. 3 Lake Park',
                        },
                    ],
                },
                {
                    key: 13,
                    name: 'Jim Green sr.',
                    age: 72,
                    address: 'London No. 1 Lake Park',
                    children: [
                        {
                            key: 131,
                            name: 'Jim Green',
                            age: 42,
                            address: 'London No. 2 Lake Park',
                            children: [
                                {
                                    key: 1311,
                                    name: 'Jim Green jr.',
                                    age: 25,
                                    address: 'London No. 3 Lake Park',
                                },
                                {
                                    key: 1312,
                                    name: 'Jimmy Green sr.',
                                    age: 18,
                                    address: 'London No. 4 Lake Park',
                                },
                            ],
                        },
                    ],
                },
            ],
        },
        {
            key: 2,
            name: 'Joe Black',
            age: 32,
            address: 'Sidney No. 1 Lake Park',
        },
    ]




    // 批量删除
    // 批量删除
    // function delAls() {
    //     selectedRowKeys.length && selectedRowKeys.map((item: any) => {
    //         // dispatch({
    //         //     type: 'page/delPageList',
    //         //     payload: item
    //         // })
    //         // dispatch({
    //         //     type: 'page/getPageList',
    //         //     payload: page
    //         // })
    //     })
    // }

    // async function confirm() {
    //     delAls();
    //     message.success('删除成功');
    //     setShow(false)
    // }

    // 分页配置
    const paginationProps: any = {
        onChange: (page: number) => handlePageChange(page), //改变页码的函数   
    }
    // 获取当前页码
    const [page, setPage] = useState(1);
    function handlePageChange(page: number) {
        setPage(page);
    }

    // 

    return <div className={styles.prodpAge}>
       
        <nav>
        </nav>
        <section>
            <div className={styles.addAndDel}>
                <Button type="primary" icon={<PlusOutlined />}>新增</Button>
            </div>
            <div className={styles.table}>

                <Table
                    columns={columns as any}
                    dataSource={data}
                    bordered
                />
            </div>


        </section>
    </div>
}

export default prodProdTag;


